<include file="Goods:leftmenu" />
<style>
#uploadPic {
	padding:0px 0px 20px 0px;
	height:auto;
}
#uploadPic ul {
	list-style-type:none;
	margin:0px;
	padding:0px;
	border:0;
	float:left;
}
#uploadPic li {
	float:left;
	width:82px;
	height:88px;
	margin:0 5px 5px 0;
	padding-bottom:3px;
	overflow:hidden;
	background:#eee;
	position:relative
}
#uploadPic .displayimg {
	width:76px;
	height:60px;
	border:1px solid #ccc;
	overflow:hidden;
	background:#fff;
	padding:2px;
	text-align:center;
	vertical-align:middle;
}
#uploadPic .displayimg img {
	width:76px;
	height:60px;
}
#uploadPic .previous {
	display:inline-block;
	width:13px;
	height:12px;
	background:url(/Static/admin/js/swfupload/img/pre-next-delete.gif) no-repeat 0 -7px;
	line-height:100px;
	vertical-align:middle;
	overflow:hidden;
	margin:-12px 33px 0 12px;
	margin:7px 33px 0 12px\9;
*margin:7px 33px 0 12px;
	_margin:7px 33px 0 12px;
}
#uploadPic .previous:hover {
	background:url(/Static/admin/js/swfupload/img/pre-next-delete.gif) no-repeat 0 -19px;
}
#uploadPic .previous:active {
	background:url(/Static/admin/js/swfupload/img/pre-next-delete.gif) no-repeat 0 -7px;
}
#uploadPic .next {
	display:inline-block;
	width:13px;
	height:12px;
	background:url(/Static/admin/js/swfupload/img/pre-next-delete.gif) no-repeat -14px -7px;
	line-height:100px;
	vertical-align:middle;
	overflow:hidden;
	margin:-12px 0 0;
	margin:7px 0 0\9;
*margin:7px 0 0;
	_margin:7px 0 0;
}
#uploadPic .next:hover {
	background:url(/Static/admin/js/swfupload/img/pre-next-delete.gif) no-repeat -14px -19px;
}
#uploadPic .next:active {
	background:url(/Static/admin/js/swfupload/img/pre-next-delete.gif) no-repeat -14px -7px;
}
#uploadPic .delete {
	display:block;
	width:13px;
	height:12px;
	background:url(/Static/admin/js/swfupload/img/closeyes.gif) no-repeat 0 0;
	line-height:100px;
	overflow:hidden;
	position:absolute;
	top:3px;
	right:3px;
	z-index:999
}
#uploadPic .delete:hover {
	background:url(/Static/admin/js/swfupload/img/close-hover.gif) no-repeat 0 0;
}
#uploadPic .front-cover {
	position:absolute;
	bottom:5px;
    *bottom:-8px;
	left:30px;
	color:#666
}
#uploadPic div {
	clear:both;
}
#uploadPic input.picDesc {
	width:80px;
*width:78px;
	text-align:center;
	margin:0;
	border:1px solid #7F9DB9;
	margin-top:2px;
	display:none;
}
#uploadPic span.upload_error {
	background-color:#FFD7D7;
	color:#000;
	padding:4px;
	font-family:Tahoma;
	line-height:24px;
}
#upload_tip {
	padding-left:15px;
	height:27px;
	line-height:27px;
}
#upload_tip span {
	color:#F30
}
.purviews {
	padding:10px 300px 10px 10px;
}
.purviews p{
	line-height:18px;
}
.purviews span {
	font-variant:normal;
	display:block;
	float:left;
	width:12%;
}
.jindubox {
	width:500px;
	margin:0 auto;
	height:30px;
	background: #CCC;
}
.jindu {
	color:#FFF;
	font-size:12px;
	font-weight:bolder;
	background:url(/Static/admin/js/swfupload/img/bfbg.gif) left top repeat-x;
	height:30px;
}
    </style>
<script type="text/javascript" src="__STATIC__admin/js/swfupload/swfupload.js" ></script>
<script type="text/javascript" src="__STATIC__admin/js/swfupload/multiupload.js?i=1" ></script>

<div class="content-right fl">
    <h1 class="content-right-title">发布商品</h1>
    
<ul class="wizard">
    <li class="wizard-item process">
        <dl class="wizard-item-content">
            <dt class="wizard-ic-step">
                <span class="wizard-icstp-num">1</span>
                <span class="wizard-icstp-title">编辑商品信息</span>
            </dt>
            <dd class="wizard-ic-desc"></dd>
        </dl>
    </li>
    <li class="wizard-item">
        <dl class="wizard-item-content">
            <dt class="wizard-ic-step">
                <span class="wizard-icstp-num">2</span>
                <span class="wizard-icstp-title">编辑商品详情</span>
            </dt>
            <dd class="wizard-ic-desc"></dd>
        </dl>
    </li>
    <li class="wizard-item">
        <dl class="wizard-item-content">
            <dt class="wizard-ic-step">
                <span class="wizard-icstp-num">3</span>
                <span class="wizard-icstp-title">发布</span>
            </dt>
        </dl>
    </li>
</ul>
<form id="form" aciton="" method="post" id="add" onsubmit="return false">

<div class="panel-single panel-single-light mgt20">
    <h3 class="cst_h3 mgb20">商品信息</h3>
    <div class="formitems">
        <label class="fi-name">商品编号：</label>
        <div class="form-controls">
            <input type="text" class="input " name="goods_bianhao" value="<?php echo $goods['goods_bianhao'];?>" >
            <span class="fi-help-text">请输入数字或字母组合</span>
        </div>
    </div>
    
	<div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>商品名称：</label>
        <div class="form-controls">
            <input type="text" class="input xxlarge" name="goods_name" value="<?php echo $goods['goods_name'];?>" maxlength="22">
            
            <span class="fi-help-text">最长22个字</span>
        </div>
    </div>

    <div class="formitems">
        <label class="fi-name"><span class="colorRed"></span>商品简介1：</label>
        <div class="form-controls">
            <input type="text" class="input xxlarge" name="desc1" value="<?php echo $goods['desc1'];?>">
            
            <span class="fi-help-text"></span>
        </div>
    </div>

    <div class="formitems">
        <label class="fi-name"><span class="colorRed"></span>商品简介2：</label>
        <div class="form-controls">
            <input type="text" class="input xxlarge" name="desc2" value="<?php echo $goods['desc2'];?>" >
            <span class="fi-help-text"></span>
        </div>
    </div>
	
    <div class="formitems">
        <label class="fi-name">商品分类：</label>
        <div class="form-controls">
			<select name="gtype_id" class="select small newselect">
				<option value="" selected="">未分类</option>
				<?php foreach($gtype as $k=>$v){ ?>
				<option value="<?php echo $v['gtype_id'];?>"  <?php echo $v['gtype_id']==$goods['gtype_id']?"selected":"";?>><?php echo $v['gtype_name'];?></option>
				<?php } ?>
			</select>
            <span class="fi-help-text">请选择商品分类</span>
        </div>
    </div>

    

    <div class="formitems">
        <label class="fi-name">市场专柜价：</label>
        <div class="form-controls">
            <input type="text" class="input mini" name="market_price" value="<?php echo $goods['market_price'];?>">
            <span>元</span>
            <span class="fi-help-text">市场售价,供参考</span>
        </div>
    </div>

   <div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>零售价：</label>
        <div class="form-controls">
            <input type="text" class="input mini"  name="shop_price" value="<?php echo $goods['shop_price'];?>">
            <span>元</span>
        </div>
    </div>
    <!--
    <?php foreach($gradeList as $grade) { ?>
        <div class="formitems">
            <label class="fi-name"><span class="colorRed">*</span><?=$grade['grade_name']?>价：</label>
            <div class="form-controls">
                <input type="text" class="input mini"  name="grade<?=$grade['grade_id']?>_price" value="<?php echo $goods['grade'.$grade['grade_id'].'_price'];?>">
                <span>元</span>
            </div>
        </div>
    <?php } ?>
    -->
     <div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>商品重量：</label>
        <div class="form-controls">
            <input type="text" class="input mini" name="goods_weight" value="<?php echo $goods['goods_weight'];?>">
            <span>千克</span>
            <span class="fi-help-text">商品重量</span>
        </div>
    </div>

    <div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>总库存：</label>
        <div class="form-controls">
            <input type="text" class="input mini" id="j-totalStock" name="stock" value="<?php echo $goods['stock'];?>">
            <span><input type="text" class="input xmini" name="unit" value="<?php echo $goods['unit'];?>"></span>
            <span class="fi-help-text">请填写库存和单位</span>
        </div>
    </div>
    
    <div class="formitems" style="display:none">
        <label class="fi-name">规格：</label>
        <div class="form-controls">
        	
        	<?php for($i=0;$i<32;$i++){ ?>
            <span><input type="text" class="input mini" name="guige[]" value="<?php echo $goods['guige'][$i]['guige_size'];?>"></span>
            <?php } ?>
            
            <span class="fi-help-text">请选填商品规格: 例如: 大号  小号  中号   或  iphone5  iphone6  iphone6s</span>
        </div>
    </div>
    
	<div id="guige-group">
	<?php if(!$guige_new){ ?>
		<div class="formitems" style="position:relative">
			<button class="btn btn-danger guige-delete" style="position:absolute;right:20px">删除</button>
			<label class="fi-name">规格：</label>
			<div class="form-controls">
				<input type="text" class="input mini" name="guige_names[]" >
				<span class="fi-help-text">请填写规格名称：例如：颜色 或 尺码</span><br>
				<?php for($i=0;$i<16;$i++){ ?>
				<span><input type="text" class="input mini" name="xx[0][]" ></span>
				<?php } ?>
				<span class="fi-help-text">请选填商品规格: 例如: 大号  小号  中号   或  iphone5  iphone6  iphone6s</span>
			</div>
		</div>
		<?php } ?>
	<?php foreach($guige_new as $key=>$vv){ ?>
		<div class="formitems" style="position:relative">
			<button class="btn btn-danger guige-delete" style="position:absolute;right:20px">删除</button>
			<label class="fi-name">规格：</label>
			
			<div class="form-controls">
				<input type="text" class="input mini" name="guige_names[]" value="<?=$guige_names[$key]?>">
				<span class="fi-help-text">请填写规格名称：例如：颜色 或 尺码</span><br>
				<?php for($i=0;$i<16;$i++){ ?>
				<span><input type="text" class="input mini" name="<?='xx['.$key.'][]'?>" value="<?=$vv[$i]?>" ></span>
				<?php } ?>
				
				<span class="fi-help-text">请选填商品规格: 例如: 大号  小号  中号   或  iphone5  iphone6  iphone6s</span>
			</div>
		</div>
	<?php } ?>
	</div>
	
	<div class="form-controls">
	<a class="fi-help-text btn btn-primary" id="add-guige" >添加规格</a>
	</div>
    
    <div class="formitems">
        <label class="fi-name">最小购买量：</label>
        <div class="form-controls">
            <input type="text" class="input mini" name="min_buy" value="<?php echo $goods['min_buy'] ? $goods['min_buy'] : 1;?>">
            <span class="fi-help-text">默认为1</span>
        </div>
    </div>
    
    <div class="formitems">
        <label class="fi-name">最大购买数：</label>
        <div class="form-controls">
            <input type="text" class="input mini" name="max_buy" value="<?php echo $goods['max_buy'] ? $goods['max_buy'] : 999999999;?>">
            <span class="fi-help-text">最大购买数,默认不限制</span>
        </div>
    </div>
    
    <div class="formitems">
        <label class="fi-name">成倍购买：</label>
        <div class="form-controls">
            <input type="text" class="input mini" name="double_buy" value="<?php echo $goods['double_buy'] ? $goods['double_buy'] : 1;?>">
            <span class="fi-help-text">必须以此数的倍数购买,默认为1</span>
        </div>
    </div>
    
    
<!--    <div class="formitems">
        <label class="fi-name"><?php echo C('SCORE_NAME');?>可用的比率：</label>
        <div class="form-controls">
            <input type="text" class="input mini" name="score_rate" value="<?php echo $goods['score_rate'];?>">
            <span class="fi-help-text">0.01~1,保留5位小数</span>
        </div>
    </div>-->
    
    <div class="formitems">
        <label class="fi-name">基础销量：</label>
        <div class="form-controls">
            <input type="text" class="input mini" name="sale_basic" value="<?php echo $goods['sale_basic'];?>">
            <span class="fi-help-text"></span>
        </div>
    </div>
    
    <div class="formitems">
        <label class="fi-name">点赞数：</label>
        <div class="form-controls">
            <input type="text" class="input mini" name="vote_nums" value="<?php echo $goods['vote_nums'];?>">
            <span class="fi-help-text"></span>
        </div>
    </div>
    
    <div class="formitems">
        <label class="fi-name">排序：</label>
        <div class="form-controls">
            <input type="text" class="input mini" name="ord" value="<?php echo $goods['ord'];?>">
            <span class="fi-help-text">数字越小越靠前,越大越靠后</span>
        </div>
    </div>
    
    <div class="formitems">
        <label class="fi-name">是否上架：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="is_free_logistics" value="1" name="ischeck" <?php echo isset($goods['ischeck']) && ($goods['ischeck']) ? "checked" : (!isset($goods['ischeck']) ? "checked":"");?>>上架</label>
                <label><input type="radio" class="is_free_logistics" value="0" name="ischeck" <?php echo isset($goods['ischeck']) && (!$goods['ischeck']) ? "checked" : "";?>>放入仓库</label>
            </div>
            <span class="fi-help-text"></span>
        </div>
    </div>
    
    <div class="formitems" style="display:none;">
        <label class="fi-name">是否特价：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="is_tejia" value="1" name="is_tejia" <?php echo isset($goods['is_tejia']) && ($goods['is_tejia']) ? "checked" : "";?>>特价</label>
                <label><input type="radio" class="is_tejia" value="0" name="is_tejia" <?php echo isset($goods['is_tejia']) && (!$goods['is_tejia']) ? "checked" : (!isset($goods['is_tejia']) ? "checked":"");?>>非特价</label>
            </div>
            <span class="fi-help-text" style="color:red;"></span>
        </div>
    </div>
    
    <div class="formitems"  style="display:none;">
        <label class="fi-name">是否折扣：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="is_zhekou" value="1" name="is_zhekou" <?php echo isset($goods['is_zhekou']) && ($goods['is_zhekou']) ? "checked" : "";?>>折扣</label>
                <label><input type="radio" class="is_zhekou" value="0" name="is_zhekou" <?php echo isset($goods['is_zhekou']) && (!$goods['is_zhekou']) ? "checked" : (!isset($goods['is_zhekou']) ? "checked":"");?>>非折扣</label>
            </div>
            <span class="fi-help-text" style="color:red;"></span>
        </div>
    </div>

    <div class="formitems">
        <label class="fi-name">是否本月新品：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="is_new" value="1" name="is_new" <?php echo isset($goods['is_new']) && ($goods['is_new']) ? "checked" : "";?>>新品</label>
                <label><input type="radio" class="is_new" value="0" name="is_new" <?php echo isset($goods['is_new']) && (!$goods['is_new']) ? "checked" : (!isset($goods['is_new']) ? "checked":"");?>>非新品</label>
            </div>
            <span class="fi-help-text" style="color:red;"></span>
        </div>
    </div>
    <div id="upload-month-new" class="formitems">
        <label class="fi-name"><span class="colorRed"></span>本月新品主图：</label>
        <div class="form-controls pdt5 j-imglistPanel">
            <input type="hidden" name="month_imgurl" value="<?=$goods['month_imgurl']?>"/>
            <div class="img">
                <?php if($goods['month_imgurl']){?>
                <img width="200" src="<?=C('UPYUN_DOMAIN').$goods['month_imgurl']?>"/>
                <?php } ?>
            </div>
            <span class="btn btn-primary j-add"><span id="upload-month-new-button">点击上传</span></span>
            <span class="fi-help-text">建议图片尺寸为640px * 300px<br>注意:仅用于商品为新品时展示于首页</span>
        </div>
    </div>
    
    <div class="formitems">
        <label class="fi-name">是否热卖单品：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="is_hot" value="1" name="is_hot" <?php echo isset($goods['is_hot']) && ($goods['is_hot']) ? "checked" : "";?>>热卖</label>
                <label><input type="radio" class="is_hot" value="0" name="is_hot" <?php echo isset($goods['is_hot']) && (!$goods['is_hot']) ? "checked" : (!isset($goods['is_hot']) ? "checked":"");?>>非热卖</label>
            </div>
            <span class="fi-help-text" style="color:red;"></span>
        </div>
    </div>
    <div id="upload-hot" class="formitems">
        <label class="fi-name"><span class="colorRed"></span>热卖单品主图：</label>
        <div class="form-controls pdt5 j-imglistPanel">
            <input type="hidden" name="hot_imgurl" value="<?=$goods['hot_imgurl']?>"/>
            <div class="img">
                <?php if($goods['hot_imgurl']){?>
                <img width="200" src="<?=C('UPYUN_DOMAIN').$goods['hot_imgurl']?>"/>
                <?php } ?>
            </div>
            <span class="btn btn-primary j-add"><span id="upload-hot-button">点击上传</span></span>
            <span class="fi-help-text">建议图片尺寸为640px * 640px<br>注意:仅用于商品为热卖单品时展示于首页</span>
        </div>
    </div>
    
    <div class="formitems">
        <label class="fi-name">是否显示购物车：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="is_free_logistics" value="1" name="is_cart" <?php echo isset($goods['is_cart']) && ($goods['is_cart']) ? "checked" : (!isset($goods['is_cart']) ? "checked":"");?>>显示</label>
                <label><input type="radio" class="is_free_logistics" value="0" name="is_cart" <?php echo isset($goods['is_cart']) && (!$goods['is_cart']) ? "checked" : "";?>>不显示</label>
            </div>
            <span class="fi-help-text"></span>
        </div>
    </div>
    
    <div class="formitems">
        <label class="fi-name">是否显示点赞框：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="is_free_logistics" value="1" name="is_vote" <?php echo isset($goods['is_vote']) && ($goods['is_vote']) ? "checked" : (!isset($goods['is_vote']) ? "checked":"");?>>显示</label>
                <label><input type="radio" class="is_free_logistics" value="0" name="is_vote" <?php echo isset($goods['is_vote']) && (!$goods['is_vote']) ? "checked" : "";?>>不显示</label>
            </div>
            <span class="fi-help-text"></span>
        </div>
    </div>
    
    <!-- 
    <div class="formitems">
        <label class="fi-name">是否需要填写身份证号码：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="is_free_logistics" value="1" name="is_idcard" <?php echo isset($goods['is_idcard']) && ($goods['is_idcard']) ? "checked" : "";?>>需要</label>
                <label><input type="radio" class="is_free_logistics" value="0" name="is_idcard" <?php echo isset($goods['is_idcard']) && (!$goods['is_idcard']) ? "checked" : (!isset($goods['is_idcard']) ? "checked":"");?>>不需要</label>
            </div>
            <span class="fi-help-text"></span>
        </div>
    </div>
    
    <div class="formitems">
        <label class="fi-name">是否需要填写IMEI：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="is_free_logistics" value="1" name="is_imei" <?php echo isset($goods['is_imei']) && ($goods['is_imei']) ? "checked" : "";?>>需要</label>
                <label><input type="radio" class="is_free_logistics" value="0" name="is_imei" <?php echo isset($goods['is_imei']) && (!$goods['is_imei']) ? "checked" : (!isset($goods['is_imei']) ? "checked":"");?>>不需要</label>
            </div>
            <span class="fi-help-text"></span>
        </div>
    </div>
     -->
    
    <div class="formitems">
        <label class="fi-name">是否显示悬浮按钮：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="is_free_logistics" value="1" name="is_xuanfu" <?php echo isset($goods['is_xuanfu']) && ($goods['is_xuanfu']) ? "checked" : (!isset($goods['is_xuanfu']) ? "checked":"");?>>显示</label>
                <label><input type="radio" class="is_free_logistics" value="0" name="is_xuanfu" <?php echo isset($goods['is_xuanfu']) && (!$goods['is_xuanfu']) ? "checked" : "";?>>不显示</label>
            </div>
            <span class="fi-help-text"></span>
        </div>
    </div>
    
    
      <div class="formitems">
        <label class="fi-name">无购物车时购买按钮文字：</label>
        <div class="form-controls">
            <input type="text" class="input xlarge" name="buy_text" value="<?php echo $goods['buy_text'];?>">
            <span class="fi-help-text"></span>
        </div>
    </div>  
    
    

    <div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>商品主图：</label>
	    <div class="form-controls pdt5 j-imglistPanel">
            <div id="uploadPic">
            <ul id="uploadlist" style=" height:90px; overflow:hidden;">
                <?php $sx=0;$p = json_decode($goods['goods_thumb'],true);foreach($p as $k=>$v){?>
                    <li>
                    <div class="displayimg"><img src="<?php echo C("UPYUN_DOMAIN").$v;?>" /></div>
                    <a class="previous" href="javascript:void(0);"></a>
                    <span class="front-cover"><?php echo $sx==0 ? "封面":"";$sx++;?></span>
                    <a class="next" href="javascript:void(0);"></a>
                    <a class="delete" href="javascript:void(0);"></a>
                    <input type="hidden" name="goods_thumb[]" id="goods_thumb" value="<?php echo $v;?>" class="goods_thumb" />
                    </li>
                <?php } ?>
            </ul>
            <div style="clear:both;"></div>
            </div>
	    <span class="btn btn-primary j-add"><span id="upload">点击上传</span></span>
	        <span class="fi-help-text">可以一次性选择多张图片上传,最对可以上传5张图片<br>建议图片尺寸为640px * 640px<br>注意:商品主图不同于商品详情图</span>
	    </div>
    </div>
</div>
<div class="panel-single panel-single-light mgt20">
    <div class="formitems">
        <label class="fi-name">佣金与升级：</label>
        <div class="form-controls">
            <select name="grade_id" class="select small newselect">
                <option value="0" selected="">不升级不分佣金</option>
                <?php foreach($gradeList as $k=>$grade){ ?>
                <option value="<?php echo $grade['grade_id'];?>"  <?php echo $goods['grade_id']==$grade['grade_id']?"selected":"";?>>升级<?php echo $grade['grade_name'];?>并按照购买<?php echo $grade['grade_name'];?>分佣</option>
                <?php } ?>
            </select>
            <span class="fi-help-text"></span>
        </div>
    </div>


    <div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>是否用于升级店长：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" value="1" name="is_grade3" <?php echo $goods['is_grade3'] ? "checked":"";?> >是</label>
                <label><input type="radio" value="0" name="is_grade3" <?php echo $goods['is_grade3'] ? "":"checked";?>>否</label>
            </div>
            <span class="fi-help-text">选择是，则该商品会显示在申请店长的页面</span>
        </div>
    </div>

    <div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>是否用于升级资深店长：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" value="1" name="is_grade4" <?php echo $goods['is_grade4'] ? "checked":"";?> >是</label>
                <label><input type="radio" value="0" name="is_grade4" <?php echo $goods['is_grade4'] ? "":"checked";?>>否</label>
            </div>
            <span class="fi-help-text">选择是，则该商品会显示在申请资深的页面</span>
        </div>
    </div>

    <div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>分佣倍数：</label>
        <div class="form-controls">
            <input type="number" class="input mini" name="yongjin_times" value="<?php echo $goods['yongjin_times'];?>">
            <span>倍</span>
            <span class="fi-help-text">如填写为2，则分佣时该商品所有相关佣金为原有的2倍</span>
        </div>
    </div>


    <!-- <div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>是否分佣：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" value="1" name="is_fx_commission" <?php echo $goods['is_fx_commission'] ? "checked":"";?> >开启</label>
                <label><input type="radio" value="0" name="is_fx_commission" <?php echo $goods['is_fx_commission'] ? "":"checked";?>>关闭</label>
            </div>
            <span class="fi-help-text">该参数已废弃，与是否分佣毫无关系</span>
        </div>
    </div> -->

    </div>


<div class="panel-single panel-single-light mgt20 j-showinhyd">
    <h3 class="cst_h3 mgb20">物流设置</h3>
    
    <div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>需要物流：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="is_free_logistics" value="1" name="is_shiwu" <?php echo $goods['is_shiwu'] ? "checked" : "";?> >需要</label>
                <label><input type="radio" class="is_free_logistics" value="0" name="is_shiwu" <?php echo $goods['is_shiwu'] ? "" : "checked";?> >不需要</label>
            </div>
            <span class="fi-help-text">会员购买免物流商品时，不需要填写收货地址。</span>
        </div>
    </div>
    
    <div class="formitems show" >
        <label class="fi-name"><span class="colorRed">*</span>运费设置：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="j-feight" value="1" name="freight_payer" <?php echo $goods['freight_payer']==1 ? "checked" : "";?>>包邮</label>
                <label><input type="radio" class="j-feight" value="2" name="freight_payer" <?php echo $goods['freight_payer']==2 ? "checked" : "";?>>统一运费</label>
            </div>
                  <input style="display:none" type="text" class="input xmini j-feight-ipt" name="shipping" value="<?php echo $goods['shipping'];?>">         
                     <span style="display:none" style="margin-right: 20px;">元</span>
            
        </div>
    </div>

</div>
<!-- end 物流及其它 -->

<div class="panel-single panel-single-light mgt20 txtCenter">

	<?php if($action=="add"){?>
	
	
	
	<?php }else{?>
	
	<a href="javascript:weSubmit(1);" class="btn btn-primary j-add">保存</a>
	
	<?php }?>



    <a href="javascript:weSubmit(2);" class="btn btn-primary j-add">保存并进入下 一 步</a>
</div>
</form>

</div>
<script src="https://cdn.bootcss.com/plupload/3.1.0/plupload.js"></script>
<script type="text/javascript">
MXI_DEBUG = false;
var uploader = new plupload.Uploader({
    browse_button: 'upload', // this can be an id of a DOM element or the DOM element itself
    url: '/admin/goods/uploadpic',
    multi_selection: false,
    filters: {
        mime_types : [
            { title : "Image files", extensions : "jpg,gif,png,jpeg" }
        ]
    },
    init: {
        FilesAdded: function (e) {
            layer.load();//正在加载
            uploader.start();
        },
        FileUploaded: function (up, file, info) {
            layer.closeAll('loading');//关闭正在加载
            info = JSON.parse(info.response);
            info = info.data.file;
            var html = '<li>'+
	          '<div class="displayimg"><img src="'+'<?php echo C("UPYUN_DOMAIN");?>'+info.savepath+info.savename+'"/></div>'+
	          '<a class="previous" href="javascript:void(0);"></a>'+
	          '<span class="front-cover"></span>'+
	          '<a class="next" href="javascript:void(0);"></a>'+
	          '<a class="delete" href="javascript:void(0);"></a>'+
	          '<input type="hidden" name="goods_thumb[]" id="goods_thumb" value="'+info.savepath+info.savename+'" class="goods_thumb" />'+
	       ' </li>';
            $('#uploadlist').append(html);
        }
    }
});
uploader.init();

var uploadArr = ['upload-month-new','upload-hot'];
uploadArr.forEach(function(item) {
    var self = item.toString();
    var uploader = new plupload.Uploader({
        browse_button: self+'-button', // this can be an id of a DOM element or the DOM element itself
        url: '/admin/goods/uploadpic',
        multi_selection: false,
        filters: {
            mime_types : [
                { title : "Image files", extensions : "jpg,gif,png,jpeg" }
            ]
        },
        init: {
            FilesAdded: function (e) {
                layer.load();//正在加载
                uploader.start();
            },
            FileUploaded: function (up, file, info) {
                layer.closeAll('loading');//关闭正在加载
                info = JSON.parse(info.response);
                info = info.data.file;
                var url = '<?php echo C("UPYUN_DOMAIN");?>'+info.savepath+info.savename;
                var html = '<img width="200" src="'+url+'"/>';
                $('#'+self+' .img').html(html);
                $('#'+self+' input').val(info.savepath+info.savename);
            }
        }
    });
    uploader.init();
})
</script>
<script>
function weSubmit(go){

	$.ajax({
		url : '/admin/goods/addGoods?goods_id=<?php echo get("goods_id");?>',
		type : "POST",
		data : $('#form').serialize(),
		dataType : 'json',
		async : false,
		success : function(data) {
			layer.closeAll('loading');//关闭正在加载
			if(data.ret == 0){
				// 成功
				var messagetype = 1;
			}else{
				// 失败
				var messagetype = 2;
			}
			if (data.url) {
				// 如果有跳转地址
				layer.msg(data.msg,{icon: messagetype}, function(){
					if(go==1){
						//不跳转
					}else{
						window.location.href = data.url;//跳转
					}
				}); 
				
			} else {
				layer.msg(data.msg, {icon: messagetype});
			}
		},
		beforeSend:function(){
			layer.load();//正在加载
       },
       error: function() {
		   layer.closeAll('loading');//关闭正在加载
		   layer.msg("网络错误,请重试", {icon: 2});
       }
       
	});
}



//运费
$(".j-feight").change(function() {
	var a = $(".j-feight-ipt"),
		b = $("#freight_tpl_id");
	switch ($(this).val()) {
	case "1":
		a.attr("disabled", !0), b.attr("disabled", !0);
		break;
	case "2":
		a.attr("disabled", !1), b.attr("disabled", !0);
		break;
	case "3":
		a.attr("disabled", !0), b.attr("disabled", !1)
	}
});

//商品pv
$("#brokerage_money").change(function() {
	var brokerage_money = $("#brokerage_money").val();
	var shop_price = $("#shop_price").val();
	brokerage_percent = brokerage_money/shop_price*100;
	
	
	$("#brokerage_percent").val(brokerage_percent);

});

$('#add-guige').on('click',function(){
	var count = $('#guige-group').children('.formitems').length;
	if(count>=2){
		layer.msg('最多只能添加两个规格哦', {icon: 7});
		return false;
		}
	var item = '<div class="formitems" style="position:relative">'+
					'<button class="btn btn-danger guige-delete" style="position:absolute;right:20px">删除</button>'+
					'<label class="fi-name">规格：</label>'+
					'<div class="form-controls">'+
						'<input type="text" class="input mini" name="guige_names[]"><br>';
	for(var i=0;i<16;i++){
		item += '<span><input type="text" class="input mini" name="xx['+(count)+'][]" ></span>';
	}
	item += '<span class="fi-help-text">请选填商品规格: 例如: 大号  小号  中号   或  iphone5  iphone6  iphone6s</span>'+
			'</div>'+
			'</div>';
			
	$('#guige-group').append(item);
})

$('#guige-group').on('click','.guige-delete',function(){
    var title = "确定要删除该规格所有内容吗？";
	var self = $(this);
	layer.confirm(title, {
	    btn: ['确定','取消'] //按钮
	}, function(){
		
		var par = self.parents(".formitems");
		par.remove();
		
		//重新排序
		var childs = $('#guige-group').children('.formitems');
		$.each(childs,function(index,item){
			$(item).find("span > input").attr('name',"xx["+index+"][]");
		});
		
		$(".layui-layer").remove();
		$(".layui-layer-shade").remove();
		
	}, function(){
		layer.msg('你取消了删除操作', {icon: 7});
	});
	
	
	
	
});
</script>